using System;
using System.Web;
using System.Web.UI;
using Jungle.Code.BLL;
using Jungle.Code.Utils;
using System.Xml;
using System.IO;

using Jungle.Modules;
using Jungle.Code.Core;

partial class NodeMenu_User : BaseUserModule
{
    private string menuType;
    protected override void OnInit(EventArgs e)
    {
        LoadOptions();
        base.OnInit(e);
    }
    // -------------------------------------------------------------------------------
    protected override void Render(HtmlTextWriter writer)
    {
        NodeMenu nMenu = new NodeMenu();
        nMenu.GetMenuItems();
        writer.Write("<ul>");
        foreach (NodeMenu it in nMenu.ItemList)
        {
            if (Node.GetByNodeID(this.section.NodeID).LangID == Node.GetByNodeID(it.NodeId).LangID)
            {
                writer.Write("<li>");
                writer.AddAttribute(HtmlTextWriterAttribute.Href, UrlHelper.GetSiteUrl() + "/" + Node.GetByNodeID(it.NodeId).RelativeUrl + ".aspx");
                writer.AddAttribute("style", "text-decoration: none; color: #000;");
                if (this.section.NodeID == it.NodeId) writer.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "bold");
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write(it.Title);
                writer.RenderEndTag();
                writer.Write("</li>");
            }
        }
        writer.Write("</ul>");
        base.Render(writer);
    }
    // -------------------------------------------------------------------------------
    private void LoadOptions()
    {
        StreamReader reader = new StreamReader(Server.MapPath("/Modules/NodeMenu/option.xml"));
        XmlDocument optionFile = new XmlDocument();
        optionFile.LoadXml(reader.ReadToEnd());
        reader.Close();

        XmlNode nodeMtype = optionFile.ChildNodes[1].ChildNodes[0];
        menuType = nodeMtype.InnerText.Trim();    
    }
    
}
